import dayjs from "dayjs";

/**
 * 默认时间
 *  获取周和月采用 dayjs 工具实现
 */
export default {
    timeOptions: {
        shortcuts: [{
            text: '今天',
            value: () => {
                const start = new Date(new Date(new Date(new Date().toLocaleDateString()).getTime()));
                const end = new Date(new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1));
                return [start, end];
            }
        },
            {
                text: '昨天',
                value: () => {
                    const start = new Date(new Date(new Date(new Date().toLocaleDateString()).getTime() - (24 * 60 * 60 * 1000)));
                    const end = new Date(new Date(new Date(new Date().toLocaleDateString()).getTime() - 1));
                    return [start, end];
                }
            },
            {
                text: '最近1天',
                value: () => {
                    const start = new Date(new Date(new Date().toLocaleDateString()).getTime() - (24 * 60 * 60 * 1000));
                    const end = new Date(new Date(new Date(new Date().toLocaleDateString()).getTime() - 1));
                    return [start, end];
                }
            },
            {
                text: '最近3天',
                value: () => {
                    const start = new Date(new Date(new Date().toLocaleDateString()).getTime() - (24 * 60 * 60 * 1000 * 3));
                    const end = new Date(new Date(new Date(new Date().toLocaleDateString()).getTime() - 1));
                    return [start, end];
                }
            },
            {
                text: '本周',
                value: () => {
                    const start = new Date(dayjs().startOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss'));
                    const end = new Date(dayjs().endOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss'));
                    return [start, end];
                }
            },
            {
                text: '上1周',
                value: () => {
                    const start = new Date(dayjs().add(-1, 'week').startOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss'));
                    const end = new Date(dayjs().add(-1, 'week').endOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss'));
                    return [start, end];
                }
            },
            {
                text: '上2周',
                value: () => {
                    const start = new Date(dayjs().add(-2, 'week').startOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss'));
                    const end = new Date(dayjs().add(-2, 'week').endOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss'));
                    return [start, end];
                }
            },
            {
                text: '本月',
                value: () => {
                    const start = new Date(dayjs().startOf('month').format('YYYY-MM-DD HH:mm:ss'));
                    const end = new Date(dayjs().endOf('month').format('YYYY-MM-DD HH:mm:ss'));
                    return [start, end];
                }
            },
            {
                text: '上1月',
                value: () => {
                    const start = new Date(dayjs().add(-1, 'month').startOf('month').format('YYYY-MM-DD HH:mm:ss'));
                    const end = new Date(dayjs().add(-1, 'month').endOf('month').format('YYYY-MM-DD HH:mm:ss'));
                    return [start, end];
                }
            },
            {
                text: '上2月',
                value: () => {
                    const start = new Date(dayjs().add(-2, 'month').startOf('month').format('YYYY-MM-DD HH:mm:ss'));
                    const end = new Date(dayjs().add(-2, 'month').endOf('month').format('YYYY-MM-DD HH:mm:ss'));
                    return [start, end];
                }
            },
            {
                text: '上3月',
                value: () => {
                    const start = new Date(dayjs().add(-3, 'month').startOf('month').format('YYYY-MM-DD HH:mm:ss'));
                    const end = new Date(dayjs().add(-3, 'month').endOf('month').format('YYYY-MM-DD HH:mm:ss'));
                    return [start, end];
                }
            },
        ]
    },
}
